<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/',function(){
//     return view('home');
    return redirect('/wechat');
});

Route::get('/home',function(){
    return view('welcome');
});

Route::get('admin/index', ['as' => 'admin.index', 'middleware' => ['auth','menu'], 'uses'=>'Admin\\IndexController@index']);


$this->group(['namespace' => 'Admin','prefix' => '/admin',], function () {
    Route::auth();
});

$router->group(['namespace' => 'Admin', 'middleware' => ['auth','authAdmin','menu']], function () {
    //权限管理路由
    Route::get('admin/permission/{cid}/create', ['as' => 'admin.permission.create', 'uses' => 'PermissionController@create']);
    Route::get('admin/permission/{cid?}', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']);
    Route::post('admin/permission/index', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']); //查询

    Route::resource('admin/permission', 'PermissionController');
    Route::put('admin/permission/update', ['as' => 'admin.permission.edit', 'uses' => 'PermissionController@update']); //修改
    Route::post('admin/permission/store', ['as' => 'admin.permission.create', 'uses' => 'PermissionController@store']); //添加


    //角色管理路由
    Route::get('admin/role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::post('admin/role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::resource('admin/role', 'RoleController');
    Route::put('admin/role/update', ['as' => 'admin.role.edit', 'uses' => 'RoleController@update']); //修改
    Route::post('admin/role/store', ['as' => 'admin.role.create', 'uses' => 'RoleController@store']); //添加


    //用户管理路由
    Route::get('admin/user/manage', ['as' => 'admin.user.manage', 'uses' => 'UserController@index']);  //用户管理
    Route::post('admin/user/index', ['as' => 'admin.user.index', 'uses' => 'UserController@index']);
    Route::resource('admin/user', 'UserController');
    Route::put('admin/user/update', ['as' => 'admin.user.edit', 'uses' => 'UserController@update']); //修改
    Route::post('admin/user/store', ['as' => 'admin.user.create', 'uses' => 'UserController@store']); //添加


    // 微信用户路由
    Route::get('admin/wechat/user/manage',['as'=>'admin.wechat.user.manage', 'uses'=>'Wechat\UserController@index']);
    Route::post('admin/wechat/user/index',['as'=>'admin.wechat.user.index',  'uses'=>'Wechat\UserController@index']);
    Route::resource('admin/wechat/user', 'Wechat\UserController');

    // 附件管理
    Route::get('admin/attach/manage',['as'=>'admin.attach.manage', 'uses'=>'AttachController@index']);

    // 楼盘管理
    Route::get('admin/build/manage', ['as'=>'admin.build.manage','uses'=>'BuildController@index']);
    Route::any('admin/build/index', ['as'=>'admin.build.index', 'uses'=>'BuildController@index']);
    Route::resource('admin/build','BuildController');
    Route::put('admin/build/update', ['as' => 'admin.build.edit', 'uses' => 'BuildController@update']); //修改
    Route::post('admin/build/store', ['as' => 'admin.build.create', 'uses' => 'BuildController@store']); //添加

    Route::get('admin/build/create/detail', ['as' =>'admin.build.create.detail', 'uses' => 'BuildController@createDetail']);
    Route::post('admin/build/store/detail', ['as' =>'admin.build.store.detail', 'uses' => 'BuildController@storeDetail']);

    Route::get('admin/build/edit/detail', ['as' =>'admin.build.edit.detail', 'uses' => 'BuildController@editDetail']);
    Route::put('admin/build/update/detail/{id}', ['as' =>'admin.build.update.detail', 'uses' => 'BuildController@updateDetail']);

    //地区管理
    Route::any('admin/areas/index', ['as'=>'admin.areas.index','uses'=>'AreasController@index']);
    Route::resource('admin/areas','AreasController');
    Route::put('admin/areas/update', ['as' => 'admin.areas.edit', 'uses' => 'AreasController@update']); //修改
    Route::post('admin/areas/store', ['as' => 'admin.areas.create', 'uses' => 'AreasController@store']); //添加

    //楼盘类型
    Route::any('admin/buildtype/index', ['as'=>'admin.buildtype.index','uses'=>'BuildTypeController@index']);
    Route::resource('admin/buildtype','BuildTypeController');
    Route::put('admin/buildtype/update', ['as' => 'admin.buildtype.edit', 'uses' => 'BuildTypeController@update']); //修改
    Route::post('admin/buildtype/store', ['as' => 'admin.buildtype.create', 'uses' => 'BuildTypeController@store']); //添加

    // 楼盘价格
    Route::any('admin/buildprice/index', ['as'=>'admin.buildprice.index','uses'=>'BuildPriceController@index']);
    Route::resource('admin/buildprice','BuildPriceController');
    Route::put('admin/buildprice/update', ['as' => 'admin.buildprice.edit', 'uses' => 'BuildPriceController@update']); //修改
    Route::post('admin/buildprice/store', ['as' => 'admin.buildprice.create', 'uses' => 'BuildPriceController@store']); //添加


    //奖品管理
    Route::get('admin/prize/manage',['as'=>'admin.prize.manage','uses'=>'PrizeController@index']);
    Route::post('admin/prize/index',['as'=>'admin.prize.index','uses'=>'PrizeController@index']);
    Route::resource('admin/prize','PrizeController');
    Route::put('admin/prize/update', ['as' => 'admin.prize.edit', 'uses' => 'PrizeController@update']); //修改
    Route::post('admin/prize/store', ['as' => 'admin.prize.create', 'uses' => 'PrizeController@store']); //添加
    // 奖品等级
    Route::any('admin/prizerank/index',['as'=>'admin.prizerank.index','uses'=>'PrizeRankController@index']);
    Route::resource('admin/prizerank','PrizeRankController');
    Route::put('admin/prizerank/update', ['as' => 'admin.prizerank.edit', 'uses' => 'PrizeRankController@update']); //修改
    Route::post('admin/prizerank/store', ['as' => 'admin.prizerank.create', 'uses' => 'PrizeRankController@store']); //添加

    // 中奖记录
    Route::any('admin/prizelog/index',['as'=>'admin.prizelog.index','uses'=>'PrizeLogController@index']);
    Route::any('admin/prizelog/export',['as'=>'admin.prizelog.export','uses'=>'PrizeLogController@export']);
    Route::resource('admin/prizelog','PrizeLogController');
    Route::put('admin/prizelog/update', ['as' => 'admin.prizelog.edit', 'uses' => 'PrizeLogController@update']); //修改
    Route::post('admin/prizelog/store', ['as' => 'admin.prizelog.create', 'uses' => 'PrizeLogController@store']); //添加

    //投票管理
    Route::get('admin/face/manage',['as'=>'admin.face.manage','uses'=>'FaceController@index']);
    Route::post('admin/face/index',['as'=>'admin.face.index','uses'=>'FaceController@index']);
    Route::resource('admin/face','FaceController');
    Route::put('admin/face/update', ['as' => 'admin.face.edit', 'uses' => 'FaceController@update']); //修改
    Route::post('admin/face/store', ['as' => 'admin.face.create', 'uses' => 'FaceController@store']); //添加

    //图片管理
    Route::any('admin/images/index',['as'=>'admin.images.index','uses'=>'ImagesController@index']);
    Route::any('admin/images/export',['as'=>'admin.images.export','uses'=>'ImagesController@export']);
    Route::resource('admin/images','ImagesController');

    Route::any('admin/index/count', ['as' => 'admin.index.count','uses'=>'IndexController@count']);


    // 上传图片
    Route::any('admin/upload/uploadimg', ['as'=>'admin.upload.uploadimg','uses'=>'UploadController@uploadImg']);

});

// 微信页面
Route::group(['prefix' => 'wechat','namespace' => 'Wechat','middleware' => ['web', 'wechat.oauth']],function () {
    //首页路由
    Route::any('/', 'IndexController@index');
    Route::any('/index/load', 'IndexController@load');
    Route::any('/index/vote/log', 'IndexController@voteLog');
    Route::any('/index/build/detailed', 'IndexController@buildDetailed');
    Route::any('/index/load/search', 'IndexController@loadSearch');
    Route::any('/callback', 'IndexController@callback');
    Route::get('/user', 'UserController@index');

    //抽奖路由
    Route::any('/draw', 'DrawController@index');
    Route::any('/draw/rand', 'DrawController@rand');
    Route::any('/draw/submit', 'DrawController@submit');
    Route::any('/draw/prize', 'DrawController@prize');
    Route::any('/draw/prize/logs', 'DrawController@prizeLog');
    //撞脸路由
    Route::any('/face', 'FaceController@index');


    //排行路由
    Route::any('/rank', 'RankController@index');
    Route::any('/rank/stars', 'RankController@stars');
    Route::any('/rank/count', 'RankController@count');
    //我的路由
    Route::any('/mine', 'MineController@index');
    Route::any('/mine/award', 'MineController@award');
    Route::any('/mine/face', 'MineController@face');
    Route::any('/mine/verify/code', 'MineController@verifyCode');
    Route::any('/mine/info/{id}', 'MineController@info');
    Route::any('/mine/submit', 'MineController@submit');
    Route::post('/mine/send/sms', 'MineController@sendSms');
    Route::any('/mine/exchange/{id}', 'MineController@exchange');

    //上传图片路由
    Route::any('/{id}/upload', 'UploadController@index');
    Route::any('/upload/uploadImg', 'UploadController@uploadImg');
    Route::any('/upload/create', 'UploadController@create');


    //楼盘列表
    Route::get('/build/index','BuildController@index');
    Route::get('/build/load','BuildController@load');


    //分享h5
    Route::get('/share','ShareController@index');
    Route::any('/share/upload/img','ShareController@upload');
    Route::any('/share/send','ShareController@send');
    Route::any('/share/test','ShareController@test');

});

// 工具
Route::group(['prefix'=>'tool','namespace'=>'Tool'],function (){
    Route::any('/', 'UploadController@index');
    Route::any('upload/uploadImg', 'UploadController@uploadImg');
    Route::any('upload/img', 'UploadController@imageUrl');
    Route::any('upload/uploadEditor', 'UploadController@uploadEditor');
    Route::any('sms','SmsController@index');
    Route::resource('test/test','TestController@test');
    Route::resource('test','TestController@index');
});



Route::get('admin', function () {
    return redirect('/admin/index');
});

Route::auth();





